#include "libc/stdint.h"

typedef struct gic_distributor{
    uint32_t GICD_CTLR;  // 启用中断和交给哪个cpu核心。
    uint32_t GICD_TYPER;  //GIC 实现是否支持两种安全状态。GIC 实现支持的最大 中断 数。可用作中断处理的 cpu核心 数量。
    uint32_t GICD_IIDR; 
    uint32_t reserved1[5];
    uint32_t implementtation_defined1[8];   //IMPLEMENTATION DEFINED
    uint32_t reserved2[16];
    uint32_t GICD_IGROUPRn[32]; 
    uint32_t GICD_ISENABLERn[32]; // 允许将相应的中断转发到 CPU 接口。
    uint32_t GICD_ICENABLERn[32];  // 禁止将相应的中断转发到 CPU 接口
    uint32_t GICD_ISPENDRn[32];
    uint32_t GICD_ICPENDRn[32]; // 从相应的中断中删除挂起状态。
    uint32_t GICD_ISACTIVERn[32];
    uint32_t GICD_ICACTIVERn[32];
    uint32_t GICD_IPRIORITYRn[255];
    uint32_t reserved3;
    uint32_t GICD_ITARGETSRn[255];
    uint32_t reserved4;
    uint32_t GICD_ICFGRn[64];
    uint32_t implementtation_defined2[64];
    uint32_t GICD_NSACRn[64];
    uint32_t GICD_SGIR;
    uint32_t reserved5[3];
    uint32_t GICD_CPENDSGIRne[4];
    uint32_t GICD_SPENDSGIRne[4];
    uint32_t reserved6[40];
    uint32_t implementtation_defined3[12];
}gic_distributor;


typedef struct gic_cpu_interface{
    uint32_t GICC_CTLR;  // 启用中断和交给哪个cpu核心。
    uint32_t GICC_PMR;
    uint32_t GICC_BPR;
    uint32_t GICC_IAR; // 保存触发中断的中断号
    uint32_t GICC_EOIR; // 设置的中断号不会循环发送中断，不会影响下一次中断
    uint32_t GICC_RPR;
    uint32_t GICC_HPPIR;
    uint32_t GICC_ABPR;
    uint32_t GICC_AIAR;
    uint32_t GICC_AEOIR;
    uint32_t GICC_AHPPIR;
    uint32_t resserved1[8];
    uint32_t implementtation_defined1[36];   //IMPLEMENTATION DEFINED
    uint32_t GICC_APRn[4];
    uint32_t GICC_NSAPRn[4];
    uint32_t resserved2[8];
    uint32_t GICC_IIDR;
    uint32_t resserved3[960];
    uint32_t GICC_DIR;
}gic_cpu_interface;

typedef struct gic_map_reg{
    gic_distributor* gicd;
    gic_cpu_interface* gicc;
}gic_map_reg;
